package com.topView2;

import java.util.*;

/**
 * @Author: huangzhigao
 * @Date: 2023/2/11 19:27
 */
public class leecode17 {
    private Map<Character, List<Character>> map = new HashMap<>();
    private List<String> res = new ArrayList<>();

    public List<String> letterCombinations(String digits) {
        if(digits == null || digits.length()==0){
            return Collections.EMPTY_LIST;
        }
        map.put('2', Arrays.asList('a', 'b', 'c'));
        map.put('3', Arrays.asList('d', 'e', 'f'));
        map.put('4', Arrays.asList('g', 'h', 'i'));
        map.put('5', Arrays.asList('j', 'k', 'l'));
        map.put('6', Arrays.asList('m', 'n', 'o'));
        map.put('7', Arrays.asList('p', 'q', 'r', 's'));
        map.put('8', Arrays.asList('t', 'u', 'v'));
        map.put('9', Arrays.asList('w', 'x', 'y', 'z'));
        char[] chars = digits.toCharArray();
        getString(chars, 0, new StringBuilder());
        return res;
    }

    public void getString(char[] chars, int index, StringBuilder stringBuilder) {
        if (index == chars.length) {
            res.add(stringBuilder.toString());
            return;
        }
        for (int i = 0; i < map.get(chars[index]).size(); i++) {
            stringBuilder.append(map.get(chars[index]).get(i));
            getString(chars, index + 1, stringBuilder);
            stringBuilder.deleteCharAt(stringBuilder.length() - 1);
        }
    }

    public static void main(String[] args) {
        leecode17 leecode17 = new leecode17();
        leecode17.letterCombinations("23");
        System.out.println("eee");
    }
}
